package com.vows.init.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import com.vows.init.config.WebConfig;

/**
 * @项目: webbit-web
 * @所属包: com.vows.init.config
 * @描述: 系统启动默认加载，替代web项目的web.xml
 * @authur:vows
 * @创建日期:2017年4月29日-下午5:29:15
 * 2017  PD.Sp Center . GDT Co.Ltd  -版权所有
 */
public class WebbitAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{
	final static Logger logger = LoggerFactory.getLogger(WebbitAppInitializer.class);
	
	
	/* 加载默认的root applicationContext
	 * @see org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer#getRootConfigClasses()
	 */
	@Override
	protected Class<?>[] getRootConfigClasses() {
		
		return new Class[]{RootConfig.class};
	}

	
	
	@Override
	protected Class<?>[] getServletConfigClasses() {
		// TODO Auto-generated method stub
		return new Class[]{WebConfig.class};
	}

	/* * 
	 * 配置DispatcherServlet 
	 * 配置一个或多个拦截路径
	 * @see org.springframework.web.servlet.support.AbstractDispatcherServletInitializer#getServletMappings()
	 */
	@Override 
	protected String[] getServletMappings() {
		logger.info("vows_sysinfo: servletMapping is '/'");
		return new String[]{"/"};
	}
	
	
	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		//servletContext.setInitParameter("", "");
		//servletContext.addListener(Log4jConfigListener.class);
		super.onStartup(servletContext);
	}

}
